#ifndef __MCS__ELIF_BRANCH__HPP
#define __MCS__ELIF_BRANCH__HPP

#include "Object.hpp"
#include "Condition.hpp"

class ElifBranch : public Object
{
public:
	ElifBranch(SourceLocation const & location, ptr<Expression> cond, ptr<Element> body)
		: Object()
		, location_(location)
		, condition_(cond)
		, body_(body)
	{
	}

	void init(Block * parentBlock)
	{
		condition_.init(parentBlock);
		body_->init(parentBlock);
	}

	bool execute() const
	{
		if(condition_.check())
		{
			body_->execute();
			return true;
		}
		return false;
	}
private:
	SourceLocation location_;
	Condition condition_;
	ptr<Element> body_;
};

#endif //__MCS__ELIF_BRANCH__HPP
